"""Initial(1)

Revision ID: 03c4c4ed0c35
Revises: 631b74bda04d
Create Date: 2023-12-23 18:47:01.748742

"""
import sqlalchemy as sa
from alembic import op
from sqlalchemy.dialects import mysql

# revision identifiers, used by Alembic.
revision = "03c4c4ed0c35"
down_revision = "631b74bda04d"
branch_labels = None
depends_on = None


def upgrade() -> None:
    # ### commands auto generated by Alembic - please adjust! ###
    op.create_table(
        "withdraw",
        sa.Column("id", sa.Integer(), nullable=False),
        sa.Column("summ", sa.Float(), nullable=False),
        sa.Column(
            "status",
            sa.Enum("on_moderation", "approved", name="withdrawstatus"),
            server_default="on_moderation",
            nullable=False,
        ),
        sa.Column("payment_method_id", sa.Integer(), nullable=True),
        sa.Column("payment_address", sa.String(length=255), nullable=False),
        sa.Column("user_id", sa.Integer(), nullable=False),
        sa.Column(
            "created_at", sa.DateTime(), server_default=sa.text("now()"), nullable=True
        ),
        sa.Column(
            "updated_at", sa.DateTime(), server_default=sa.text("now()"), nullable=True
        ),
        sa.ForeignKeyConstraint(
            ["payment_method_id"],
            ["payment_details.id"],
            name=op.f("fk_withdraw_payment_method_id_payment_details"),
        ),
        sa.ForeignKeyConstraint(
            ["user_id"], ["user.id"], name=op.f("fk_withdraw_user_id_user")
        ),
        sa.PrimaryKeyConstraint("id", name=op.f("pk_withdraw")),
    )
    op.drop_column("user", "is_approved")
    # ### end Alembic commands ###


def downgrade() -> None:
    # ### commands auto generated by Alembic - please adjust! ###
    op.add_column(
        "user",
        sa.Column(
            "is_approved",
            mysql.TINYINT(display_width=1),
            server_default=sa.text("'0'"),
            autoincrement=False,
            nullable=False,
        ),
    )
    op.drop_table("withdraw")
    # ### end Alembic commands ###
